package demo2;

public class Main {
    public static void main(String[] args) {
        Girl girl = new Girl();
        girl.setName("宝贝");

        Proxy proxy = new Proxy(girl); //代理类

        proxy.GiveDoll();
        proxy.GiveFlowers();
        proxy.GiveChocolate();
    }
}


class Girl{//女孩类
    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
interface IGiveGift{//送礼物接口
    void GiveDoll();
    void GiveFlowers();
    void GiveChocolate();
}

class Pursuit implements IGiveGift{//追求者类
    Girl girl;

    public Pursuit(Girl girl) {
        this.girl = girl;
    }

    @Override
    public void GiveDoll() {
        System.out.println(girl.getName()+ " 送你洋娃娃");
    }

    @Override
    public void GiveFlowers() {
        System.out.println(girl.getName()+ " 送你花");
    }

    @Override
    public void GiveChocolate() {
        System.out.println(girl.getName()+ " 送你巧克力");
    }
}

class Proxy implements IGiveGift{//代理类
    Pursuit pursuit;
    public Proxy(Girl girl){
        pursuit = new Pursuit(girl);
    }
    @Override
    public void GiveDoll() {
        pursuit.GiveDoll();
    }

    @Override
    public void GiveFlowers() {
        pursuit.GiveFlowers();
    }

    @Override
    public void GiveChocolate() {
        pursuit.GiveChocolate();
    }
}
